package com.isyscore.mapper.admin;

import com.isyscore.dto.sys.ListUserForm;
import com.isyscore.dto.sys.UserDto;
import com.isyscore.entity.admin.SysUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户信息表 Mapper 接口
 * </p>
 *
 * @author LGL
 * @since 2024年10月25日
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {

    /**
     * 根据用户ID查询权限
     * @param userId
     * @return
     */
    @Select("select distinct m.perms from sys_role_menu rm " +
            "inner join sys_menu m on rm.menu_id = m.menu_id " +
            "where rm.role_id " +
            "in (select role_id from sys_user_role where user_id = #{userId})")
    List<String> findPermissionsByUserId(Long userId);
    /**
     * 获取用户列表
     * @param form
     * @return
     */
    List<UserDto> listUsers(ListUserForm form);

    /**
     * 获取用户列表总数
     * @param form
     * @return
     */
    Integer listUsersTotal(ListUserForm form);
}
